<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <meta http-equiv="X-UA-Compatible" content="ie=edge" />
    <title>Document</title>
  </head>
  <body>
    <div id="app">
      <banner-com></banner-com>
      <div>父组件内部----------------------------{{bdata}}</div>
      <list-com></list-com>
    </div>
    <template id="banner">
      <div>
        <h1>我是banner子组件</h1>
        <h1>{{bdata}}</h1>
        <h1>父组件的数据：{{fdata}}</h1>
        <banner-item></banner-item>
        <hr />
      </div>
    </template>
    <template id="list">
      <div>
        <h1>我是list子组件</h1>
        <h1 @click="say">{{ldata}}</h1>
        <h1>父组件的数据：{{fdata}}</h1>
        <hr />
      </div>
    </template>
    <template id="bannerItem">
      <div>
        <h1>{{itemdata}}</h1>
      </div>
    </template>
    <script src="vue.js"></script>
    <script>
      // Vue.component('组件名', { 配置项 })
      var vm = new Vue({
        el: '#app',
        data() {
          return {
            fmsg: '父组件数据'
          }
        },
        components: {
          //创建局部组件
          bannerCom: {
            template: '#banner',
            data() {
              return {
                bdata: 'banner数据'
              }
            },
            components: {
              bannerItem: {
                template: '#bannerItem',
                data() {
                  return {
                    itemdata: 'banner子组件数据'
                  }
                }
              }
            },
            methods: {}
          },
          listCom: {
            template: '#list',
            data() {
              return {
                ldata: '列表的数据'
              }
            },
            methods: {
              say() {
                alert('你好')
              }
            }
          }
        },
        methods: {}
      })
    </script>
  </body>
</html>
